#include "engine_error.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char *get_err_msg(int errnum)
{
    switch (errnum)
    {
        case ENGINE_EBADFILE: return strdup("Operation with Bad file");
        break;
        case ENGINE_EBADHNDL: return strdup("Operation with Bad handle");
        break;
        case ENGINE_EPTHREADERROR: return strdup("Operation with bad pthread");
        default: return strdup("Unknown ERROR");
    }
}

void engine_error(char mode, int errnum, const char *str)
{
    switch  (mode)
    {
        case ENGINE_ALC_ERROR: fprintf(stderr, "ALC Device errror %s\n", str);
        break;
        case ENGINE_AL_ERROR: fprintf(stderr, "Open Al  error %s\n", str);
        break;
        case ENGINE_ENGINE_ERROR:
        char *msg = get_err_msg(errnum);
        fprintf(stderr, "Engine Error %s\n", msg);
        free(msg);
    }
}
